
 /*
 Data loader for spreadsheet under GNU general public liscence
 */
 
/**
 *
 * @author lanchana
 * @ DataLoader for spreadsheet
 * @ email:lanch.gunawardhana@gmail.com
 */
package forms;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;


class TblModel extends AbstractTableModel {

private List data;
private int columnCount;
public TblModel(List data,int colCount) {
this.data = data;
this.columnCount=colCount;
}
public int getColumnCount() {
return columnCount ;
}
public int getRowCount() {
return data == null ? 0 : data.size();
}
public void setValueAt(Object value, int rowIndex, int columnIndex) {
getRecord(rowIndex)[columnIndex] = value;
super.fireTableCellUpdated(rowIndex, columnIndex);
}
public Object getValueAt(int rowIndex, int columnIndex) {
return getRecord(rowIndex)[columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return true;
}
public Class getColumnClass(int columnIndex) {
if (data == null || data.size() == 0) {
return Object.class;
}
Object o = getValueAt(0, columnIndex);
return o == null ? Object.class : o.getClass();
}
private Object[] getRecord(int rowIndex) {
return (Object[]) data.get(rowIndex);
}

}
